package com.debao.web.controller.debao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.debao.common.annotation.Log;
import com.debao.common.core.controller.BaseController;
import com.debao.common.core.domain.AjaxResult;
import com.debao.common.enums.BusinessType;
import com.debao.system.domain.VipcardOrder;
import com.debao.system.service.IVipcardOrderService;
import com.debao.common.utils.poi.ExcelUtil;
import com.debao.common.core.page.TableDataInfo;

/**
 * 会员卡订单Controller
 * 
 * @author DeBao
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/debao/vipCardOrder")
public class VipcardOrderController extends BaseController
{
    @Autowired
    private IVipcardOrderService vipcardOrderService;

    /**
     * 查询会员卡订单列表
     */
    @PreAuthorize("@ss.hasPermi('debao:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(VipcardOrder vipcardOrder)
    {
        startPage();
        List<VipcardOrder> list = vipcardOrderService.selectVipcardOrderList(vipcardOrder);
        return getDataTable(list);
    }

    /**
     * 导出会员卡订单列表
     */
    @PreAuthorize("@ss.hasPermi('debao:order:export')")
    @Log(title = "会员卡订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VipcardOrder vipcardOrder)
    {
        List<VipcardOrder> list = vipcardOrderService.selectVipcardOrderList(vipcardOrder);
        ExcelUtil<VipcardOrder> util = new ExcelUtil<VipcardOrder>(VipcardOrder.class);
        util.exportExcel(response, list, "会员卡订单数据");
    }

    /**
     * 获取会员卡订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('debao:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vipcardOrderService.selectVipcardOrderById(id));
    }

    /**
     * 新增会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:add')")
    @Log(title = "会员卡订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VipcardOrder vipcardOrder)
    {
        return toAjax(vipcardOrderService.insertVipcardOrder(vipcardOrder));
    }

    /**
     * 修改会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:edit')")
    @Log(title = "会员卡订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VipcardOrder vipcardOrder)
    {
        return toAjax(vipcardOrderService.updateVipcardOrder(vipcardOrder));
    }

    /**
     * 删除会员卡订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:remove')")
    @Log(title = "会员卡订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vipcardOrderService.deleteVipcardOrderByIds(ids));
    }
}
